#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int MAX=2e5+10;
int n;
struct node{
	int val,lst,nxt;
}a[MAX];
bool vis[MAX];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i].val);
	for(int i=1;i<=n;i++){
		a[i].lst=i-1;
		a[i].nxt=i+1;
	}
	int cnt=n;
	a[0].val=-1;
	a[0].nxt=1;
	while(cnt){
		int x=-1;
		for(int i=0;i<=n;i=a[i].nxt){
			if(a[i].val!=x){
				cnt--;
				printf("%d ",i);
				x=a[i].val;
				vis[i]=1;
				a[a[i].lst].nxt=a[i].nxt;
				a[a[i].nxt].lst=a[i].lst;
			}
		}
		printf("\n");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
